//
//  ByFeedbackVC.m
//  recordworktool_ios
//
//  Created by mc on 2017/12/26.
//  Copyright © 2017年 ZhangZhanbin. All rights reserved.
//

#import "ByFeedbackVC.h"
#import "ByTextView.h"

@interface ByFeedbackVC ()

@property (nonatomic, strong) ByTextView *textView;

@end

@implementation ByFeedbackVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self addLeftBackBarButtonItem];
    self.title = @"意见反馈";
    
    [self initViews];
    // Do any additional setup after loading the view.
}

- (void)initViews{
    
    self.view.backgroundColor = BY_BACKGROUND_COLOR;
    ByTextView *textView = [[ByTextView alloc] initWithFrame:CGRectMake(0, 10, SCREEN_WIDTH, 150)];
    [self.view addSubview:textView];
    textView.textColor = [UIColor grayColor];
    textView.font = FONT(16);
    textView.placeholder = @"请留下您的意见或建议，平台将尽快在此板块进行回复。谢谢！";
    self.textView = textView;
    
    UIButton *submitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:submitBtn];
    [submitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(10);
        make.right.equalTo(self.view).offset(-10);
        make.top.equalTo(textView.mas_bottom).offset(20);
        make.height.mas_equalTo(@40);
    }];
    submitBtn.backgroundColor = BY_THEME_COLOR;
    [submitBtn setTitle:@"提交" forState:UIControlStateNormal];
    [submitBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    submitBtn.titleLabel.font = FONT(16);
    submitBtn.layer.cornerRadius = 5;
    [submitBtn addTarget:self action:@selector(submitAction:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)submitAction:(UIButton *)btn{
    if (self.textView.text.length == 0) {
        [ByCoreToolAlert showOnlyText:@"反馈内容不能为空"];
        return;
    }
    NSLog(@"提交");
    ByNetModel *netModel = [[ByNetModel alloc] init];
    netModel.suggest_content = self.textView.text;
    netModel.uid = BY_USER.uid;
    netModel.tel = BY_USER.mobile;
    [ByCoreToolAlert showLoadind:@"提交中" hasMasker:YES];
    [ByApiUser  suggestAdd:netModel success:^(ByNetBaseResult *result) {
        [ByCoreToolAlert showSuccessWithText:@"提交成功"];
        [self dismissViewControllerAnimated:YES completion:nil];
        
    } failure:^(ByNetBaseResult *result) {
        [ByCoreToolAlert showFailureWithText:result.msg];
    }];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
